<?php

/**
 * reports actions.
 *
 * @package    ldaad
 * @subpackage reports
 * @author     Ymaura
 * @version    SVN: $Id: actions.class.php 2692 2006-11-15 21:03:55Z fabien $
 */
class reportsActions extends sfActions
{
  /**
   * Executes index action
   * redirects to select a conf if no conference is selected
   */
  public function executeIndex()
  {
    $conf = ConferencePeer::retrieveByPK($this->getRequestParameter('id'));
	if(!$conf){
		$this->redirect('reports/selectconf');
	}
	$this->kirby = $conf->getName();
	$this->confid = $conf->getID();
  }
	/*
	* Lets user select a conference
	*/
  public function executeSelectconf(){
	$this->conflist = ConferencePeer::doSelect(new Criteria());
  }
	/*
	* Financial reports
	*/
	public function executeBasefinance(){
	$conf = ConferencePeer::retrieveByPK($this->getRequestParameter('id'));
	//redirect if there is no specified conference
	if(!$conf){
		$this->redirect('reports/selectconf');
	}
	$this->confid = $conf->getId();
	$this->dontot = $conf->getDonationtotal();
	$this->feetot = $conf->getFeetotal();
	}
	
	public function executeSubfinance(){
	$conf = ConferencePeer::retrieveByPK($this->getRequestParameter('id'));
	//redirect if there is no specified conference
	if(!$conf){
		$this->redirect('reports/selectconf');
	}
	$this->confregs = $conf->getRegistrations();
	}
	
	/*
	* Donation reports
	*/
	public function executeBasedonation(){
		$conf = ConferencePeer::retrieveByPK($this->getRequestParameter('id'));
		//redirect if there is no specified conference
		if(!$conf){
			$this->redirect('reports/selectconf');
		}
		$this->confregs = $conf->getRegistrations();
		
	}
	
	/*
	* Conference Reports
	*/
    
	public function executeBaseconference(){
	$conf = ConferencePeer::retrieveByPK($this->getRequestParameter('id'));
	//redirect if there is no specified conference
	if(!$conf){
		$this->redirect('reports/selectconf');
	}
    
 
	$this->confName = $conf->getName();
    $this->confID = $conf->getId();
	$this->numreg = $conf->countRegistrations();
	$this->numfsess = $conf->countFullsessions();
	$this->numsess = $conf->countSessions();
	$this->numfevent = $conf->countFullevents();
    $this->numevent = $conf->countSpecialEvents();
	}
	
	public function executeRegistration(){
		$conf = RegistrationPeer::retrieveByPK($this->getRequestParameter('id'));
		//redirect if there is no specified conference
		if(!$conf){
			$this->redirect('reports');
		}
		$this->reg = $conf;
	}
    
    /*
	* Session Reports
	*/
    public function executeBasesession(){
        $conf = ConferencePeer::retrieveByPK($this->getRequestParameter('id'));
        //redirect if there is no specified conference
        if(!$conf){
            $this->redirect('reports/selectconf');
        }
       // $this->numreg = $conf->countRegistrations();
        $criteria = new Criteria();
        $criteria->addAscendingOrderByColumn(SessionPeer::TIME_START);
       // $criteria2 = new Criteria();
       // $criteria2->addAscendingOrderByColumn(SpecialEventPeer::TIME_START);

        
        $this->confName = $conf->getName();
        $this->sessions = $conf->getSessions($criteria);
       // $this->events = $conf->getSpecialEvents($criteria2);
	
	}
	
	    public function executeBaseevent(){
        $conf = ConferencePeer::retrieveByPK($this->getRequestParameter('id'));
        //redirect if there is no specified conference
        if(!$conf){
            $this->redirect('reports/selectconf');
        }
     //   $this->numreg = $conf->countRegistrations();
        //$criteria = new Criteria();
        //$criteria->addAscendingOrderByColumn(SessionPeer::TIME_START);
        $criteria2 = new Criteria();
        $criteria2->addAscendingOrderByColumn(SpecialEventPeer::TIME_START);

        
        $this->confName = $conf->getName();
        //$this->sessions = $conf->getSessions($criteria);
        $this->events = $conf->getSpecialEvents($criteria2);
	
	}
	
	public function executeSession(){
        $conf = ConferencePeer::retrieveByPK($this->getRequestParameter('id'));
		$curpage = 1;

		$idd = $conf->getId();

        $criteria = new Criteria();
        $criteria->addAscendingOrderByColumn(SessionPeer::TIME_START);
        $criteria->add(SessionPeer::CONFERENCE_ID, $idd);
        
        $this->confName = $conf->getName();
		$pager = new sfPropelPager('Session', 3);
		$pager->setCriteria($criteria);
		$pager->setPage($curpage);
		$pager->init();
		$this->pager = $pager;
		$this->id = $idd;
       
	
	}
    
    /*
            * Session Roster
            */
    public function executeSessionroster(){
        $sess = SessionPeer::retrieveByPK($this->getRequestParameter('id'));
        $this->name = $sess->getName();
        $this->code = $sess->getSessionCode();
        $conf = $sess->getConference();
        $this->confname = $conf->getName();
        $this->reg = $sess->getSessionRegistrations();
    }
     
     /*
            * Special Event Roster
            */  
    public function executeEventroster(){
        $event = SpecialEventPeer::retrieveByPK($this->getRequestParameter('id'));
        $this->name = $event->getName();
        $this->code = $event->getSpecialCode();
        $this->reg = $event->getSpecialEventRegistrations();
        
        $conf = $event->getConference();
        $this->confname = $conf->getName();

    }
        /*
            * Special Event Roster
            */  
    public function executeConfroster(){
        $conf = ConferencePeer::retrieveByPK($this->getRequestParameter('id'));
        //redirect if there is no specified conference
        if(!$conf){
            $this->redirect('reports/selectconf');
        }
        $this->confregs = $conf->getRegistrations();
        $this->confname = $conf->getName();
        

    }
    
	/*
	*   Mailing Labels
	*/
	public function executeMailing(){
        $conf = ConferencePeer::retrieveByPK($this->getRequestParameter('id'));
        //redirect if there is no specified conference
        if(!$conf){
            $this->redirect('reports/selectconf');
        }
        $this->confregs = $conf->getRegistrations();      

    }
	
	/*
	*   Badges
	*/
	public function executeBadges(){

        $conf = ConferencePeer::retrieveByPK($this->getRequestParameter('id'));
        //redirect if there is no specified conference
        if(!$conf){
            $this->redirect('reports/selectconf');
        }
		
        $this->confregs = $conf->getDefaultbadges();
        
    }
	/*
	*   Badges
	*/
	public function executeAllbadges(){

        $conf = ConferencePeer::retrieveByPK($this->getRequestParameter('id'));
        //redirect if there is no specified conference
        if(!$conf){
            $this->redirect('reports/selectconf');
        }
		
        $this->confregs = $conf->getRegistrations();
        
    }
	
}
